Cartograflow is designed to easily create thematic origin-destination (OD) flowmaps, based on the articulation of a matrice (an OD flow dataset) and a background map (a spatial shape).
This Vignette presents different functions that are mainly used to prepare the flowdata set. The spatial objects processing are those of {sp} and the mapping elements are often those of {Cartography} except, for example, the design of arrows.
Two matrice formats are available
– List format : “L” for “list” is a .csv 3 column flow dataset (origin, destination, flow_value) ;
– Matrice format : “M” for “Matrice” is a .csv [n*n] flow dataset.
– Use flowtabmat() in order to transform a “L” to “M” matrice format and vice versa.
In the case you only have a list of spatial units (code,X,Y), you can also generate an empty square matrice with flowtabmat()
At least two datasets are required
– a statistical dataset : a .csv “L” or “M” flow dataset ;
– a geographical dataset :
a .shp (correctly georeferenced) spatial objet (geometry : polygon) corresponding to the background map
or a .csv consisting of a list of spatial spatial units consisting of 3 columns (code, X, Y).
– flowcarre() is to transform an un-square to a square matrice from a list of spatial objets ID (code)
– flowjointure() is to performs a spatial join between a flow dataset and a map background
– flowtabmat() is to transform a “M” matrice format to a “L” format and vice versa
– flowstructmat() fixes an unpreviously ID shift in the flow dataset “M” format. If necessary this function is to be used with flowjointure() and flowtabmat.
It is to decide firstly to zero or not the diagonal, see {base::diag}.
– flowtype() is to compute the main types of flows from an asymmetric flow dataset (matrice or list format). The result is a bilateral gross or net flows matrice.
It is also possible to compute the matrice’s margins in order to calculate probabilities of sending and receiving flows or all kinds of indicators. Use for that the R {base} or {dplyr}
– flowgini() performs a concentration analysis of a flow dataset - To be use before flowanalysis()
computes Gini coefficient
plot Lorenz curve
– flowanalysis() is to be used after flowgini() for computing a flow filter based on a double criterion for selecting flows before mapping :
level of flow thresholding, and the corresponding ;
desired threshold level of flow’s information significativity (% of total of flow information) ;
or
You have two ways to consider the distance travelled by flows : – if you have a matrice distance, go directly to flowreduct() at §2.2.3 ;
– if not, you can continue here, and have to choose the type of metric (continous or ordinal)
flowjointure(), then use flowdist() as described below– flowjointure() performs an attribute spatial join - by origin (i) and by destination (j) - between a flow dataset and a spatial shape in order to transfert the origin-destination coordinates (Xi, Yi, Xj, Yj) of the base map to the flow matrice.
– flowdist() Computes a continous distance matrice choosing metric (only euclidian for this first version)
Computes on the resulting continous distance matrice at least a {base::summary} in order to select a distance filter criterion, then a flowreduct() and finally the flowmap() function.
– flowcontig() compute an ordinal distance distance matrice based on a k-contiguity matrice. (k) is the order parameter, it is the number of borders to be crossed between origins and destinations places.
ordre=1, origin-destination places are adjacent ;
ordre=2, origin-destination places are distant from 2 borders ;
ordre=4, origin-destination places are distant from 4 borders.
Use after flowreduct() function and directly flowmap() without applying the filter parameter.
You can also map the neighbourhood spatial graph using flowmap() without applying the filter parameter.
– flowreduct() is to perform the reduction of the flow dataset according to another matrice (especially a matrice distance)
flowmap() is to create a layer of lines and plot them, using a flow dataset and a spatial shape.
– filtre is to choose to map all or selected matrice’s cases.
If filtre is “FALSE”, all the N(N-1) theoretical values are drawn.
else (If filtre is “TRUE”) you need to filter flow’s values or features.
– seuil is to apply a numerical global (across the whole matrice) flow selection criterion.
You can apply an empirical criterion or use a robust one in the statistical meaning.
For robust filter criterion, use :
{base::summary} to compute univariate flows’ statistics such as mean, median, quantile, etc.) or
use {flowanalysis} after {flowgini} : compute the critflow parameter to estimate a selection criterion based on the significance of the flow’s information.
{flowanalysis} after {flowgini} : compute the critlink parameter to estimate a selection criterion based on the density of the flows’ features.For doing a map collection, one can use for example :
{cartography::getBreaks} for computing a new numeric flow vector of breaks using well-known methods (quantile, geometrics, etc.)– taille is to modify the width of the origin-destination lines.
– a.fleche is to determine the kind of arrows to be drawn from places (in, out, in and out).
– a.length is to parameter the length of the arrow head in relation to the body of the arrow.
– a.angle is to parameter an angle from the shaft of the arrow to the edge of the arrow head.
– a.col is to parameter the color of the arrows.
– a.alpha is to parameter of opacity
To dress and decorate the map by addin a legend layer, a north or south arrow, a scale, etc., see :
– {cartography::layoutLayer}
– {graphics::legend}
Inter-municipality professional mobility in Greater Paris.
rm(list=ls())
library(dplyr)
library(sf)
library(cartography)
library(cartograflow)– Statistical dataset : extraction from the “Mobilités professionnelles en 2015 : déplacements domicile - lieu de travail” from the french census (Recensement de la population) - Base flux de mobilité, file.
-URL : https://www.insee.fr/fr/statistiques/fichier/3566008/rp2015_mobpro_txt.zip
– Geographical dataset :
municipalities : IGN, GEOFLA® 2015 v2.1 Communes France Métropolitaine.
geographical ID : INSEE, 2016.
Citations : IGN - GEOFLA 2015, UMS 2414 RIATE, 2018
data<-read.csv2("./data/tab_MGP_mobpro.csv",header=TRUE,sep=";",stringsAsFactors=FALSE,
encoding="UTF-8",dec=".",check.names=FALSE)
head(data)## CODGEO LIBGEO DCLT L_DCLT
## 1 75101 Paris 1er Arrondissement 75102 Paris 2e Arrondissement
## 2 75101 Paris 1er Arrondissement 75105 Paris 5e Arrondissement
## 3 75101 Paris 1er Arrondissement 75108 Paris 8e Arrondissement
## 4 75101 Paris 1er Arrondissement 75109 Paris 9e Arrondissement
## 5 75101 Paris 1er Arrondissement 75112 Paris 12e Arrondissement
## 6 75101 Paris 1er Arrondissement 75113 Paris 13e Arrondissement
## NBFLUX_C14_ACTOCC15P
## 1 247
## 2 104
## 3 426
## 4 263
## 5 123
## 6 139
tabflow<-data%>%
select(CODGEO,DCLT,NBFLUX_C14_ACTOCC15P)
colnames(tabflow)<-c("i","j","Fij")
head(tabflow)## i j Fij
## 1 75101 75102 247
## 2 75101 75105 104
## 3 75101 75108 426
## 4 75101 75109 263
## 5 75101 75112 123
## 6 75101 75113 139
str(tabflow)## 'data.frame': 4692 obs. of 3 variables:
## $ i : int 75101 75101 75101 75101 75101 75101 75101 75101 75101 75101 ...
## $ j : int 75102 75105 75108 75109 75112 75113 75115 75116 92012 92026 ...
## $ Fij: int 247 104 426 263 123 139 134 123 128 139 ...
#typage des variables
tabflow$i<-as.character(tabflow$i)
tabflow$j<-as.character(tabflow$j)
tabflow$Fij<-as.numeric(tabflow$Fij)
ID_CODE<-read.csv2("./data/COD_GEO_MGP.csv",header=TRUE,sep=";",stringsAsFactors=FALSE,encoding="UTF-8",dec=".",check.names=FALSE)
head(ID_CODE)## COD_GEO
## 1 75101
## 2 75102
## 3 75103
## 4 75104
## 5 75105
## 6 75106
CODE<-ID_CODE%>%select(COD_GEO)
colnames(CODE)<-c("CODGEO")
#CODE = as.data.table(CODE)
head(CODE)## CODGEO
## 1 75101
## 2 75102
## 3 75103
## 4 75104
## 5 75105
## 6 75106
#str(CODE)
#typage des variables
#CODE$CODGEO<-as.character(CODE$CODGEO)#change matrice format (if necessary)
matflow <-flowtabmat(tabflow,matlist="M")## Using Fij as value column: use value.var to override.
## warning:your matrix is not square!
head(matflow[1:4,1:4])## 75101 75102 75103 75104
## 75101 0 247 0 0
## 75102 286 0 115 0
## 75103 379 410 0 224
## 75104 232 207 183 0
dim(matflow)## [1] 141 183
#The Warning says that the matrice is note square.Dimension is 141x183 that is why we make it square, using cartograflow::flowcarre
matflow.sq<-flowcarre(CODE,tabflow,"i","j","Fij",format = "M",diagonale = TRUE,empty.sq = FALSE)## 'data.frame': 150 obs. of 1 variable:
## $ CODGEO: int 75101 75102 75103 75104 75105 75106 75107 75108 75109 75110 ...
## Using ydata as value column: use value.var to override.
## great:your matrix is square!
head(matflow.sq[1:4,1:4])## 75101 75102 75103 75104
## 75101 0 247 0 0
## 75102 286 0 115 0
## 75103 379 410 0 224
## 75104 232 207 183 0
dim(matflow.sq)## [1] 150 150
# zero the diagonal of matrice format (if necessary)
# mat_nodiag<-matflow.sq
# diag(mat_nodiag) <- 0
# head(mat_nodiag[1:4,1:4])
# re change matrice format
# tabflow_nodiag <-flowtabmat(tab=mat_nodiag,
# matlist="L")
# colnames(tabflow_nodiag) <- c("i","j","Fij")
# head(tabflow_nodiag)#matflow <-mat_nodiag
# Compute bilateral volume - from a "M" format
matflow_vol<-flowtype(tab=matflow.sq,
format="M","bivolum")
# Compute bilateral volume - from a "L" format
tabflow.sq<-flowtabmat(matflow.sq,matlist = "L")
# Compute only bilateral volume or net flows in one 3 column "L" format matrice
# FSij will be the gross Fij flow values
tabflow_vol<-flowtype(tabflow,
format="L","bivolum")
head(tabflow_vol)## i j FSij
## 1 75101 75102 533
## 2 75101 75105 460
## 3 75101 75108 727
## 4 75101 75109 742
## 5 75101 75112 1003
## 6 75101 75113 1110
# FDij will be the net Fij flow values
tabflow_sold<-flowtype(tabflow,
format="L","bisold")
head(tabflow_sold)## i j FDij
## 1 75101 75102 39
## 2 75101 75105 252
## 3 75101 75108 -125
## 4 75101 75109 216
## 5 75101 75112 757
## 6 75101 75113 832
#compute all types in one 6 columns "L" format matrice
tabflow_all<-flowtype(tabflow,
format="L",
x="all")
head(tabflow_all) ## i j Fij Fji FSij FDij
## 1 75101 75102 247 286 533 39
## 2 75101 75105 104 356 460 252
## 3 75101 75108 426 301 727 -125
## 4 75101 75109 263 479 742 216
## 5 75101 75112 123 880 1003 757
## 6 75101 75113 139 971 1110 832
#compute and flow asymetry
tabflow_all$FAsy<-(tabflow_all$FDij / tabflow_all$FDij)*100Data= “tabflow.sq” Basemap= “MGP_communes.shp”
knitr::opts_chunk$set(fig.width=6, fig.height=6)
# Plot all theoretical OD links (no filter)
flowmap(tab = tabflow.sq,
format="L",
fdc="./data/MGP_communes.shp",
code="IDCOM",
filtre=FALSE)## All theorical links are plotted
mtext("All theoretical relations",side = 3)#Plot all existing relations
flowmap(tab = tabflow.sq,
format="L",
fdc="./data/MGP_communes.shp",
code="IDCOM",
filtre=TRUE,
a.col="#3f4247",
seuil=1, #flow values up to 1
taille=1,
a.fleche = 0)
mtext("All existing relations ",side = 3)#Plot only flow values up to 100 (the french INSEE's)
flowmap(tab = tabflow.sq,
format="L",
fdc="./data/MGP_communes.shp",
code="IDCOM",
filtre=TRUE,
a.col="#3f4247",
seuil=100, #flow value > 100
taille=5, #graphic parameteter
a.fleche = 1, #add arrow
a.length = 0.11)
mtext("Existing flows up to 100",side = 3)tabflow.sq<-tabflow.sq %>% filter(tabflow.sq$ydata!=0)
#extraction des quantiles
summary(tabflow.sq$ydata)## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 100.0 145.0 228.0 357.1 403.0 4857.0
decile<-c(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1)
quantile(tabflow.sq$ydata,decile)## 0% 10% 20% 30% 40% 50% 60% 70% 80% 90%
## 100.0 116.0 133.4 157.0 187.0 228.0 277.0 350.0 472.2 748.0
## 100%
## 4857.0
#Plot all flow up to Q3
par(mar=c(0,0,1,0))
extent <- c(2800000, 1340000, 6400000, 4800000)
resolution<-300
flowmap(tab = tabflow.sq,
format="L",
fdc="./data/MGP_communes.shp",
code="IDCOM",
filtre=TRUE,
a.col="#3f4247",
seuil=748, #flow value > 748 (90% information)
taille=5, #graphic parameteter
a.fleche = 1, #add arrow
a.length = 0.11)
mtext("Existing flows up to 748 - 90% information",side = 3)# LIST FORMAT
#--------------------
tabflow.sq<-flowtabmat(matflow.sq,matlist = "L")
# 1- Computes Gini coefficient
#--------------------
tab_gini<-flowgini(tabflow.sq,
format="L",
origin="i",
dest="j",
valflow="ydata",
fdc = "./data/MGP_communes.shp",
code="IDCOM",
lorenz.plot = FALSE)## coefficient de gini = 44.13 %
head(tab_gini)## i j ydata X1 Y1 X2 Y2 link flowcum
## 1067 75117 75108 4857 649165.4 6865479 649575.7 6863852 1 0.003117114
## 1065 75115 75108 4852 648097.2 6860237 649575.7 6863852 1 0.006231019
## 1066 75116 75108 4000 645848.7 6862519 649575.7 6863852 1 0.008798130
## 1068 75118 75108 3560 652206.2 6866034 649575.7 6863852 1 0.011082859
## 2281 92012 75116 3263 644144.9 6859859 645848.7 6862519 1 0.013176979
## 4515 75115 92012 3142 648097.2 6860237 644144.9 6859859 1 0.015193445
## linkcum
## 1067 0.0002292001
## 1065 0.0004584002
## 1066 0.0006876003
## 1068 0.0009168004
## 2281 0.0011460005
## 4515 0.0013752006
# 2- Plot Lorenz curve
#--------------------
flowgini(tab_gini,
format="L",
origin="i",
dest="j",
valflow="ydata",
fdc = "./data/MGP_communes.shp",
code="IDCOM",
lorenz.plot = TRUE)# 3- Compute critflow parameter and flowmap
#-------------------------------
#critflow = 0.02 (2% of the largest flows)
flowanalysis(tab_gini,
critflow = 0.02,
result = "signif")## [1] "seuil = 3070 --- flows = 2 % --- links = 0.18 %"
#seuil = 3070 - 2% flows - 0,1% links
par(mar=c(0,0,1,0))
flowmap(tabflow.sq,
format="L",
fdc="./data/MGP_communes.shp",
code="IDCOM",
filtre=TRUE,
seuil=1176,
taille=5,
a.fleche = 1,
a.length = 0.11,
a.angle = 30,
a.col="#3f4247")
mtext("significative flowmap : values up to 3070 - 2% flow information - 0,1% links",side = 3)
# 4- Compute critlink parameter and flowmap
#-------------------------------
flowanalysis(tab_gini,
critlink = 0.01,
result = "density")## [1] "seuil = 2045 --- flows = 7.21 % --- links = 1 %"
# Plot 4 % of the total features, flow greater than 2015
par(mar=c(0,0,1,0))
flowmap(tab = tabflow.sq,
format="L",
fdc="./data/MGP_communes.shp",
code="IDCOM",
filtre=TRUE,
a.col="#3f4247",
seuil=2045,
taille=5,
a.fleche = 1,
a.length = 0.11,
a.angle = 30
)
mtext("Small density flowmap : values up to 2045 - 7,21 flow information - 1% links",side = 3)library(cartography)
par(mar=c(0,0,1,0))
extent <- c(2800000, 1340000, 6400000, 4800000)
resolution<-300
# Flow map
flowmap(tabflow.sq,
format="L",
fdc="./data/MGP_communes.shp",
code="IDCOM",
filtre=TRUE,
seuil=2045, # Min value
taille=4, #taille max du plus gros flux
a.fleche = 1,
a.length = 0.11,
a.angle = 30,
a.col="#3f4247")
# Legend
##---------------
legendPropLines(pos="topleft",
title.txt="Number of commuters",
title.cex=1, # taille du titre de la legende
cex=0.8,
values.cex= 0.7, # size of the values in the legend.
var=c(2045,max(tabflow.sq$ydata)), # # Min - Max flow value
lwd=4, #taille max du plus gros flux
frame = FALSE,
col="#3f4247",
values.rnd = 0
)
layoutLayer(title = "Professional mobility in Greater Paris : the strongest 1%",
author = "Cartograflow, 2019",
sources = "Sources : data : INSEE, RP, MOBPRO, 2017 ; basemap : IGN - GEOFLA 2015, UMS 2414 RIATE, 2018",
scale = 5,
tabtitle = TRUE,
frame = TRUE,
north(pos = "topright"),
col = "grey",
coltitle ="black")
# Add territorial boundaries
fdc_ter <- st_read("./data/MGP_territoires.shp", stringsAsFactors = F)## Reading layer `MGP_territoires' from data source `D:\R\package\cartograflow\vignettes\data\MGP_territoires.shp' using driver `ESRI Shapefile'
## Simple feature collection with 12 features and 14 fields
## geometry type: POLYGON
## dimension: XY
## bbox: xmin: 2.145699 ymin: 48.64615 xmax: 2.615706 ymax: 49.01233
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
# Harmonizing projections
prj <- 2154
fdc_ter <- st_transform(fdc_ter, prj)
plot(fdc_ter$geometry, col=NA, border="#332d2e",lwd=1.9, add=T)tab<-flowjointure(tabflow.sq,"./data/MGP_communes.shp","IDCOM")
tab.distance<-flowdist(tab,dist.method = "euclidian",result = "dist")
#summarise (for example) to find mean, dmin or dmax
summary(tab.distance$distance)## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0 8879 13642 14135 18971 36867
#reduce the flow dataset from a selected distance travelled < 4506 m (corresponding to Q1)
tab.flow<-flowreduct(tabflow.sq,
tab.distance,
metric = "continous",
select = "dmax", #max distance parameter
d = 4056) #max distance value
#select for all i,j flow values up to 0
flow.d<-tab.flow%>%
select(i,j,flowfilter)%>%
filter(flowfilter !=0)
flowmap(flow.d,format="L","./data/MGP_communes.shp","IDCOM",
filtre = TRUE,
a.col="#3f4247",
a.length = 0.11,
a.fleche =1)## warning : you use the default threshold= 1
mtext("Professional mobility less than 4506 meters (Q1)")
## Final flowmap less than 4,5 km
#dev.off() #nettoyage fenetre graphique
par(mar=c(0,0,1,0))
extent <- c(2800000, 1340000, 6400000, 4800000)
resolution<-300
flowmap(flow.d,format="L","./data/MGP_communes.shp","IDCOM",
filtre = TRUE,
taille = 4,
a.col="#3f4247",
a.length = 0.11,
a.fleche =1)## warning : you use the default threshold= 1
plot(fdc_ter$geometry, col=NA, border="black",lwd=1.9, add=T)
legendPropLines(pos="topleft",
title.txt="Number of commuters",
title.cex=1, # taille du titre de la legende
cex=0.8,
values.cex= 0.7, # size of the values in the legend.
var=c(min(flow.d$flowfilter),max(flow.d$flowfilter)), # Min - Max de la serie
col="#3f4247",
lwd=4, #taille max du plus gros flux défini ds flowmap
frame = FALSE,
values.rnd = 0
)
# Habillage
layoutLayer(title = "Professional mobility in Greater Paris : distance travelled less than 4.5 km",
author = "Cartograflow, 2019",
sources = "Sources : data : INSEE, RP, MOBPRO, 2017 ; basemap : IGN - GEOFLA 2015, UMS 2414 RIATE, 2018",
scale = 5,
tabtitle = TRUE,
frame = TRUE,
north(pos = "topright"),
col = "grey",
coltitle ="black")## Neighbouring graph (ordre 1)
graph_ckij_1<-flowcontig("./data/MGP_communes.shp","IDCOM",ordre =1)
flowmap(graph_ckij_1,
format="L",
"./data/MGP_communes.shp","IDCOM",
filtre = TRUE,
taille = 0.5)## warning : you use the default threshold= 1
mtext("Neighbouring graph (ordre 1)",
side=3)
## Reducing flow matrice by the neighbouring graph (ordre 1)
reduc<-flowreduct(tabflow.sq,graph_ckij_1,metric = "ordinal")
flow.c<-reduc %>%
select(i,j,flux)%>%
filter(flux!=0)
## Plot adjacent flows
flowmap(flow.c,format="L","./data/MGP_communes.shp","IDCOM",
filtre = TRUE,
taille = 2,
a.col="#3f4247",
a.length = 0.11,
a.fleche =1)## warning : you use the default threshold= 1
mtext("Adjacent flows",
side=3)
## Final adjacent flowmap
#dev.off() #nettoyage fenetre graphique
par(mar=c(0,0,1,0))
extent <- c(2800000, 1340000, 6400000, 4800000)
resolution<-300
flowmap(flow.c,format="L","./data/MGP_communes.shp","IDCOM",
filtre = TRUE,
taille = 4,
a.col="#3f4247",
a.length = 0.1,
a.fleche =1)## warning : you use the default threshold= 1
# Add territorial boundaries
fdc_ter <- st_read("./data/MGP_territoires.shp", stringsAsFactors = F)## Reading layer `MGP_territoires' from data source `D:\R\package\cartograflow\vignettes\data\MGP_territoires.shp' using driver `ESRI Shapefile'
## Simple feature collection with 12 features and 14 fields
## geometry type: POLYGON
## dimension: XY
## bbox: xmin: 2.145699 ymin: 48.64615 xmax: 2.615706 ymax: 49.01233
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
prj <- 2154
fdc_ter <- st_transform(fdc_ter, prj)
plot(fdc_ter$geometry,
col=NA,
border="#332d2e",
lwd=1.9,
add=T)
# Add Legend
legendPropLines(pos="topleft",
title.txt="Number of commuters",
title.cex=1, # taille du titre de la legende
cex=0.8,
values.cex= 0.7, # size of the values in the legend.
var=c(min(flow.c$flux),max(flow.c$flux)), # Min - Max de la serie
col="#3f4247",
lwd=4, #taille max du plus gros flux défini ds flowmap
frame = FALSE,
values.rnd = 0
)
# Habillage
layoutLayer(title = "Professional mobility in Greater Paris between neighbouring municipalities",
author = "Cartograflow, 2019",
sources = "Sources : data : INSEE, RP, MOBPRO, 2017 ; basemap : IGN - GEOFLA 2015, UMS 2414 RIATE, 2018",
scale = 5,
tabtitle = TRUE,
frame = TRUE,
north(pos = "topright"),
col = "grey",
coltitle ="black")
#mtext("Note : Only flows between adjacent municipalities are plot",
# side=2)## Neighbouring graph (ordre 2)
graph_ckij_2<-flowcontig("./data/MGP_communes.shp","IDCOM",ordre =2)
head(graph_ckij_2)## i j ydata
## 1 75102 75109 2
## 2 75103 75109 2
## 3 75104 75109 2
## 4 75105 75109 2
## 5 75106 75109 2
## 6 75107 75109 2
flowmap(graph_ckij_2,
format="L",
"./data/MGP_communes.shp","IDCOM",
filtre = TRUE,
taille = 0.5)## warning : you use the default threshold= 1
mtext("Neighbouring graph (order 2)",
side=3)
## Reducing flow matrice by the neighbouring graph (ordre 2)
reduc2<-flowreduct(tabflow.sq,graph_ckij_2,metric = "ordinal")
flow.c2<-reduc2 %>%
select(i,j,flux)%>%
filter(flux!=0)
## Plot adjacent flows
flowmap(flow.c2,format="L","./data/MGP_communes.shp","IDCOM",
filtre = TRUE,
taille = 4,
a.length = 0.11,
a.fleche =1)## warning : you use the default threshold= 1
mtext("Flows between municipalities distant from 2 boundaries",
side=3)library(sf)
## Final adjacent flowmap
#dev.off() #nettoyage fenetre graphique
par(mar=c(0,0,1,0))
extent <- c(2800000, 1340000, 6400000, 4800000)
resolution<-300
flowmap(flow.c2,format="L","./data/MGP_communes.shp","IDCOM",
filtre = TRUE,
taille = 4,
a.length = 0.11,
a.fleche =1,
a.col = "#3f4247")## warning : you use the default threshold= 1
legendPropLines(pos="topleft",
title.txt="Number of commuters",
title.cex=1, # taille du titre de la legende
cex=0.8,
values.cex=0.7, # size of the values in the legend.
var=c(min(flow.c2$flux),max(flow.c2$flux)), # Min - Max de la serie
col="#3f4247",
lwd=4, #taille max du plus gros flux défini ds flowmap
frame = FALSE,
values.rnd = 0
)
#Habillage
layoutLayer(title = "Professional mobility in Greater Paris between municipalities from two boundaries",
author = "Cartograflow, 2019",
sources = "Sources : data : INSEE, RP, MOBPRO, 2017 ; basemap : IGN - GEOFLA 2015, UMS 2414 RIATE, 2018",
scale = 5,
tabtitle = TRUE,
frame = TRUE,
north(pos = "topright"),
col = "grey",
coltitle ="black")
#mtext("Note : Only flows between municipalities distant by 2 boundaries are plot",
# side=2)
# Import de fonds
fdc_ter <- st_read("./data/MGP_territoires.shp", stringsAsFactors = F)## Reading layer `MGP_territoires' from data source `D:\R\package\cartograflow\vignettes\data\MGP_territoires.shp' using driver `ESRI Shapefile'
## Simple feature collection with 12 features and 14 fields
## geometry type: POLYGON
## dimension: XY
## bbox: xmin: 2.145699 ymin: 48.64615 xmax: 2.615706 ymax: 49.01233
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
prj <- 2154
fdc_ter <- st_transform(fdc_ter, prj)
# Add territorial limits
#plot(fdc_com$geometry, col=NA, border="blue",lwd=0.2)
plot(fdc_ter$geometry, col=NA, border="#332d2e",lwd=1.9, add=T)
#plot(fdc_lim$geometry,col=NA,border="red",lwd=1.5,add=T)sessionInfo()## R version 3.5.2 (2018-12-20)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 15063)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=C LC_CTYPE=French_France.1252
## [3] LC_MONETARY=French_France.1252 LC_NUMERIC=C
## [5] LC_TIME=French_France.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] bindrcpp_0.2.2 cartography_2.1.2 sf_0.7-2
## [4] dplyr_0.7.8 cartograflow_0.0.0.9000
##
## loaded via a namespace (and not attached):
## [1] httr_1.4.0 pkgload_1.0.2 tidyr_0.8.2
## [4] jsonlite_1.6 viridisLite_0.3.0 shiny_1.2.0
## [7] assertthat_0.2.0 sp_1.3-1 yaml_2.2.0
## [10] remotes_2.0.2 sessioninfo_1.1.1 pillar_1.3.1
## [13] backports_1.1.3 lattice_0.20-38 glue_1.3.0
## [16] digest_0.6.18 promises_1.0.1 colorspace_1.3-2
## [19] httpuv_1.4.5.1 htmltools_0.3.6 plyr_1.8.4
## [22] pkgconfig_2.0.2 devtools_2.0.1 xtable_1.8-3
## [25] purrr_0.2.5 scales_1.0.0 processx_3.2.1
## [28] later_0.7.5 tibble_2.0.0 ggplot2_3.1.0
## [31] usethis_1.4.0 withr_2.1.2 lazyeval_0.2.1
## [34] cli_1.0.1 mime_0.6 magrittr_1.5
## [37] crayon_1.3.4 memoise_1.1.0 maptools_0.9-4
## [40] evaluate_0.12 ps_1.3.0 fs_1.2.6
## [43] xml2_1.2.0 foreign_0.8-71 class_7.3-14
## [46] pkgbuild_1.0.2 tools_3.5.2 data.table_1.12.0
## [49] prettyunits_1.0.2 stringr_1.3.1 plotly_4.8.0
## [52] munsell_0.5.0 callr_3.1.1 compiler_3.5.2
## [55] e1071_1.7-0 rlang_0.3.0.1 classInt_0.3-1
## [58] units_0.6-2 grid_3.5.2 rstudioapi_0.8
## [61] htmlwidgets_1.3 crosstalk_1.0.0 labeling_0.3
## [64] rmarkdown_1.11 testthat_2.0.1 gtable_0.2.0
## [67] DBI_1.0.0 roxygen2_6.1.1 g.data_2.4
## [70] reshape2_1.4.3 R6_2.3.0 knitr_1.21
## [73] rgdal_1.3-6 rgeos_0.4-2 bindr_0.1.1
## [76] commonmark_1.7 rprojroot_1.3-2 desc_1.2.0
## [79] stringi_1.2.4 Rcpp_1.0.0 tidyselect_0.2.5
## [82] xfun_0.4